<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
  <title>Document</title>
</head>
<body>
  <div id="coolDiv"></div>
</body>
<script>
  let coolDiv = document.querySelector("#coolDiv");
  let shadow = coolDiv.attachShadow({mode: "open"});
  shadow.innerHTML = `
      <style>
        #mySpan{
          color:#ccc;
        }
      </style>
      <span id="mySpan">这就是shadow dom</span>`;

  console.log(document.querySelector("#mySpan"));
</script>
</html>